// app.js
App({
  onLaunch() {
    // 检测程序更新
    const updateManager = wx.getUpdateManager()
    updateManager.onUpdateReady(function () {
      wx.showModal({
        title: '更新提示',
        content: '检测到新版本，点击确定更新重启应用获得全新体验！',
        success: function (res) {
          updateManager.applyUpdate()
        }
      })
    })
    wx.login({
      success: res => {
        console.log(res);
      }
    })
    // 实现摇一摇 弹出提示框 
    // todo  一键呼救
    var showModel = false
    wx.startAccelerometer({})
    wx.onAccelerometerChange(function (e) {
      if (e.x > 1 && e.y > 1 && showModel == false) {
        showModel = true
        wx.showModal({
          title: '提示',
          content: '5s后将进行自动呼救！',
          showCancel: false,
          confirmText: "取消",
          success(res) {
            if (res.confirm) {
              return false
            }
          },
          complete: c => {
            showModel = false
          }
        })
      }
    })
  },
  globalData: {
    userInfo: null
  }
})